#ifndef PACK_H
#define PACK_H

#include "../libSDL/include/SDL_thread.h"
#include "avformat.h"
#define PACKET_NO 40
#define BUF_NO 20
#define AUD_BUF_SZ (16*1024)
#define VID_BUF_SZ (64*1024)
typedef struct {
	AVPacketList pktl[PACKET_NO];
	int id_g, id_p;
	int size;
    SDL_mutex *mutex;
    SDL_cond *cond;
} pack;
typedef struct {
	unsigned char buf[BUF_NO][AUD_BUF_SZ];
	int id_g, id_p;
	int size;
    SDL_mutex *mutex;
    SDL_cond *cond;
} array_aq;
typedef struct {
	unsigned char buf[BUF_NO][VID_BUF_SZ];
	int id_g, id_p;
	int size;
    SDL_mutex *mutex;
    SDL_cond *cond;
} array_vq;

#ifdef PACK_GLOBAL
  #define PACK_EXT
#else
  #define PACK_EXT extern
#endif

PACK_EXT pack audio_pack, video_pack;
PACK_EXT array_aq rep_a;
PACK_EXT array_vq rep_v;
PACK_EXT unsigned char buf_other[VID_BUF_SZ];
PACK_EXT void rep_init(void);
PACK_EXT void pack_init(pack *pa);
PACK_EXT int repa_get(AVPacket * pkt, int size);
PACK_EXT void repa_put(AVPacket *pkt);
PACK_EXT int repv_get(AVPacket * pkt, int size);
PACK_EXT int rep_get(AVPacket * pkt, int size);
PACK_EXT void repv_put(AVPacket *pkt);
PACK_EXT AVPacketList * pack_get(pack * pa);
PACK_EXT void pack_put(pack * pa);

#endif /* PACK_H */
